<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/config.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/model/SystemManager.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/model/PageManager.php';

$flag = $_REQUEST['flag'];

switch ($flag) {
    case 'login':
        $system = new SystemManager();
        $login = $system->login($_POST['username'], $_POST['password']);
        echo $login;
        break;
    case 'logout':
        $system = new SystemManager();
        $system->logout();
        break;
    case 'goToPage':
        $pageManager = new PageManager();
        $pageManager->goToPage($_REQUEST['pageName']);
        break;
    case 'mysqlQuery':
        $system = new SystemManager();
        $data = $system->mysqlQuery($_POST['query']);
        echo $data;
        break;
    default:
        header('Location: ' . ROOT_ADDRESS);
}
?>
